<!DOCTYPE html>
<html lang="en" onclick="star(event)">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>

</body>
<script>
    function star(e) {
        let obj = document.createElement('img');
        obj.src = 'img/star.gif';
        let sq = Math.floor(Math.random()*(150-5)+5);//5-150随机整数
        obj.width = sq;
        obj.style.position = 'absolute';
        obj.style.top = e.clientY - sq/2 + 'px';
        obj.style.left = e.clientX - sq/2 + 'px';
        document.body.appendChild(obj);
    }
</script>
</html>